# -*- coding: utf-8 -*-
"""
created on 2017/12/7 14:47

@author: didichen
"""


# http://www.pythonchallenge.com/pc/def/oxygen.html
# http://www.pythonchallenge.com/pc/def/integrity.html

# 主要描述了PIL的用法
import requests
from PIL import Image

url = 'http://www.pythonchallenge.com/pc/def/oxygen.png'

# r = requests.get(url)
# with open("oxygen.png", "wb") as fr:
#     fr.write(r.content)

img = Image.open('oxygen.png')
w, h = img.size
print(w, h)

for i in range(0,w):
    print(i, 50, img.getpixel((i, 50)))
# 检查结果
# 0 50 (115, 115, 115, 255)
# 1 50 (115, 115, 115, 255)
# 2 50 (115, 115, 115, 255)
# 3 50 (115, 115, 115, 255)
# 4 50 (115, 115, 115, 255)
# 5 50 (109, 109, 109, 255)
# 6 50 (109, 109, 109, 255)
# 7 50 (109, 109, 109, 255)
# 8 50 (109, 109, 109, 255)
# 9 50 (109, 109, 109, 255)
# 10 50 (109, 109, 109, 255)
# 11 50 (109, 109, 109, 255)

data = [chr(img.getpixel((i,50))[0]) for i in range(0,609,7)]
print(''.join(data))
# smart guy, you made it. the next level is [105, 110, 116, 101, 103, 114, 105, 116, 121]

data = [105, 110, 116, 101, 103, 114, 105, 116, 121]
data_char = [chr(v) for v in data]
print(''.join(data_char))
# integrity
